# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from django.shortcuts import render
from api_application.base_api import BaseApi

"""
监控平台接口
https://bk.tencent.com/docs/document/6.0/130/13199
https://bkmonitor.paas-edu.bktencent.com/
# 通过蓝鲸监控接口获取告警中心信息 以机器维度进行告警分析数据统计
"""

# 开发框架中通过中间件默认是需要登录态的，如有不需要登录的，可添加装饰器login_exempt
# 装饰器引入 from blueapps.account.decorators import login_exempt
monitor_api = BaseApi()


def monitor(request):
    """
    监控页
    """

    return render(request, "home_application/monitor.html", {
    })


def strategy(request):
    # 查询告警策略
    search_alarm_strategy_v3 = {}
    resp_search_alarm_strategy_v3 = monitor_api.requests("POST", "search_alarm_strategy_v3", {"bk_biz_id": 2})
    if resp_search_alarm_strategy_v3.get("result", False):
        search_alarm_strategy_v3 = resp_search_alarm_strategy_v3["data"]

    # 查询全业务告警策略
    search_alarm_strategy_without_biz = {}
    # resp_search_alarm_strategy_without_biz = monitor_api.requests("POST", "search_alarm_strategy_without_biz")
    # if resp_search_alarm_strategy_without_biz.get("result", False):
    #     search_alarm_strategy_without_biz = resp_search_alarm_strategy_without_biz["data"]

    return render(request, 'home_application/strategy.html', {
        "search_alarm_strategy_v3": search_alarm_strategy_v3,
        "search_alarm_strategy_without_biz": search_alarm_strategy_without_biz
    })


def collect_running_status(request):
    # 获取采集配置主机的运行状态
    pass


# 配置告警策略，是否通过API来配置？
def add_shield(request):
    # 新增告警屏蔽
    pass


def disable_shield(request):
    # 解除告警屏蔽
    pass


def edit_shield(request):
    # 编辑告警屏蔽
    pass


def list_shield(request):
    # 获取告警屏蔽列表
    pass


def delete_alarm_strategy(request):
    # 删除告警策略
    pass


def search_alarm_strategy(request):
    # 查询告警策略
    pass


def metadata_list_result_table(request):
    # 查询监控结果表
    pass


def save_alarm_strategy(request):
    # 保存告警策略
    pass


def switch_alarm_strategy(request):
    # 启停告警策略
    pass


def search_event(request):
    # 查询事件
    pass


# 获取当前业务下的异常告警，并根据当前业务的拓扑结构进行告警的统计分析
def search_alarm_strategy_without_biz(request):
    # 查询全业务告警策略
    pass


def metadata_list_result_table(request):
    # 获取业务的拓扑结构
    "/api/c/compapi/v2/monitor_v3/metadata_list_result_table/"
    pass


def metadata_list_result_table(request):
    # 查询监控结果表
    self.requests("post", "{0}/api/c/compapi/v2/monitor_v3/metadata_list_result_table/".format(self.host))
    pass


def metadata_get_data_id(request):
    # 获取监控数据源具体信息
    pass


def get_collect_config_list(request):
    # 采集配置列表
    pass


def toggle_collect_config_status(request):
    # 启停采集配置
    pass


def save_collect_config(request):
    # 创建/保存采集配置
    pass


def get_collect_log_detail(request):
    # 获取采集下发详细日志
    pass


def collect_running_status(request):
    # 获取采集配置主机的运行状态
    pass
